package com.szrt.cookie.utils;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

public class CookieUtil {


	public static Cookie getCookie(HttpServletRequest request,String key){
		Cookie c = null;
		Cookie[] cookies = request.getCookies();
		
		for(Cookie cookie: cookies){
			System.out.println("key:"+ cookie.getName());
			System.out.println("value:"+ cookie.getValue());
			if(cookie.getName().equals(key)){
				c = cookie;
				break;
			}
		}
		return c;
	}
}
